<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class C_jabatan extends CI_Controller {
	function C_jabatan(){
		parent::__construct();
		if($this->auth->is_logged_in() == false){
			redirect('c=c_login','refresh');
		}
		$this->load->model('m_jabatan', '', TRUE);
	}
	
	public function index(){
		$this->load->view('main/v_jabatan');
	}
	
	function get_list(){
		$result=$this->m_jabatan->get_list();
		echo $result;
	}
	
	function get_unitkerja_list(){
		$result=$this->m_public_function->get_unitkerja_list();
		echo $result;
	}
	
	//event handler action
	function get_action(){
		$task = $_POST['task'];
		switch($task){
			case "CREATE":
				$this->create();
				break;
			case "UPDATE":
				$this->update();
				break;
			default:
				echo "{failure:true}";
				break;
		}
	}
	
	function create(){
		$kodeunit=trim(@$_POST["kodeunit"]);
		$kodeunit=htmlentities($kodeunit,ENT_QUOTES);
		$kodejab=trim(@$_POST["kodejab"]);
		$kodejab=htmlentities($kodejab,ENT_QUOTES);
		$namajab=trim(@$_POST["namajab"]);
		$namajab=htmlentities($namajab,ENT_QUOTES);
		$hitunglembur=trim(@$_POST["hitunglembur"]);
		$hitunglembur=htmlentities($hitunglembur,ENT_QUOTES);
		$kompencuti=trim(@$_POST["kompencuti"]);
		$kompencuti=htmlentities($kompencuti,ENT_QUOTES);
		
		$result=$this->m_jabatan->create($kodeunit, $kodejab, $namajab, $hitunglembur, $kompencuti);
		echo $result;
	}
	
	function update(){
		$kodeunit_lama=@$_POST["kodeunit_lama"];
		$kodeunit_lama=is_numeric($kodeunit_lama)?$kodeunit_lama:0;
		$kodeunit=trim(@$_POST["kodeunit"]);
		$kodeunit=htmlentities($kodeunit,ENT_QUOTES);
		$kodejab_lama=@$_POST["kodejab_lama"];
		$kodejab_lama=is_numeric($kodejab_lama)?$kodejab_lama:0;
		$kodejab=trim(@$_POST["kodejab"]);
		$kodejab=htmlentities($kodejab,ENT_QUOTES);
		$namajab=trim(@$_POST["namajab"]);
		$namajab=htmlentities($namajab,ENT_QUOTES);
		$hitunglembur=trim(@$_POST["hitunglembur"]);
		$hitunglembur=htmlentities($hitunglembur,ENT_QUOTES);
		$kompencuti=trim(@$_POST["kompencuti"]);
		$kompencuti=htmlentities($kompencuti,ENT_QUOTES);
		
		$result=$this->m_jabatan->update($kodeunit_lama, $kodeunit, $kodejab_lama, $kodejab, $namajab, $hitunglembur, $kompencuti);
		echo $result;
	}
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */